<?php defined('SYSPATH') or die(); ?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>思途CMS{$coreVersion}</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('style.css,base.css,base_new.css,equity.css'); }
    {php echo Common::getScript("config.js"); }
</head>
<body>
<!--顶部-->
<table class="content-tab">
    <tr>
        <td valign="top" class="content-rt-td" style="overflow:auto;">
            <div class="product-add-wrap pl-20">
                <form id="configfrm">
                    <ul class="info-item-block">
                        <li>
                            <span class="item-hd">等级计算规则{Common::get_help_icon('member_grade_rule')}：</span>
                            <div class="item-bd">
                                <span class="item-text">
                                    <label class="radio-label mr-10">
                                        <input name="cfg_member_grade_rule" type="radio" value="1" {if $cfg_member_grade_rule==1}checked{/if}>按累计积分计算
                                    </label>
                                    <label class="radio-label mr-10">
                                        <input name="cfg_member_grade_rule" type="radio" value="2" {if $cfg_member_grade_rule==2}checked{/if}>按剩余积分计算
                                    </label>
                                    {if St_Functions::is_normal_app_install('system_wallet')}
                                    <label class="radio-label mr-10">
                                        <input name="cfg_member_grade_rule" type="radio" value="3" {if $cfg_member_grade_rule==3}checked{/if}>按充值金额
                                    </label>
									{/if}
                                </span>
                            </div>
                        </li>
                    </ul>
                </form>
            </div>
            <div class="clear text-c f-0 mt-30 mt-10">
                <a href="javascript:;" class="btn btn-primary radius ml-20" onclick="save_rule()">确定</a>
            </div>
        </td>
    </tr>
</table>
<script>
    var org_grade_rule = "{$cfg_member_grade_rule}";
    function save_rule()
    {
        var msg = '确定切换？';
        var cfg_member_grade_rule = $("input[name='cfg_member_grade_rule']:checked").val();
        if(org_grade_rule!=3 && cfg_member_grade_rule==3){
            msg = '切换为充值升级后，部分平台老用户的等级将受到影响或降级，所有等级规则也将强制修改为充值升级，还需重新配置等级规则，确定切换吗？';
        }else if(org_grade_rule==3 && cfg_member_grade_rule!=3){
            msg = '切换为积分升级后，已充值的用户等级，会随着积分区间的等级规则发生改变，确定切换吗?';
        }
        ST.Util.confirmBox("提示", msg, function () {
            $.ajax({
                type:"POST",
                url:"/newtravel/membergrade/ajax_save_rule",
                data:{cfg_member_grade_rule:cfg_member_grade_rule},
                dataType:'json',
                success:function(data){
                    org_grade_rule = cfg_member_grade_rule;
                    ST.Util.showMsg('保存成功!','4',2000);
                }
            })
        })
    }
</script>
</body>
</html>